﻿using System.Security.Cryptography;
using System.Text;
using Microsoft.Win32;

namespace SlideShowDFG2
{
    public class CryptographyHelper
    {
        public static byte[] EncryptString(string value)
        {
            return ProtectedData.Protect(Encoding.UTF8.GetBytes(value), new RegistryHelper().Entropy, DataProtectionScope.LocalMachine); 
        }
        
        public static string DecryptString(byte[] value)
        {
            return Encoding.UTF8.GetString(ProtectedData.Unprotect(value, new RegistryHelper().Entropy, DataProtectionScope.LocalMachine));
        }
        
        private byte[] GetEntropy()
        {
            RegistryHelper helper = new RegistryHelper();
            return helper.Entropy;
        }
    }
}
